/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.Entity.SIS;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author user12
 */
@Entity
@Table(name = "SIS_COURSES")
@NamedQueries({
    @NamedQuery(name = "Course.findAll", query = "SELECT s FROM Course s"),
    @NamedQuery(name = "Course.findByCourseNo", query = "SELECT s FROM Course s WHERE s.courseNo = :courseNo"),
    @NamedQuery(name = "Course.findByCourseCode", query = "SELECT s FROM Course s WHERE s.courseCode = :courseCode"),
    @NamedQuery(name = "Course.findByCourseName", query = "SELECT s FROM Course s WHERE s.courseName = :courseName"),
    @NamedQuery(name = "Course.findByCourseNameS", query = "SELECT s FROM Course s WHERE s.courseNameS = :courseNameS"),
    @NamedQuery(name = "Course.findByCrdHrs", query = "SELECT s FROM Course s WHERE s.crdHrs = :crdHrs"),
    @NamedQuery(name = "Course.findByIsAvg", query = "SELECT s FROM Course s WHERE s.isAvg = :isAvg"),
    @NamedQuery(name = "Course.findByIsTraining", query = "SELECT s FROM Course s WHERE s.isTraining = :isTraining"),
    @NamedQuery(name = "Course.findByIsThesis", query = "SELECT s FROM Course s WHERE s.isThesis = :isThesis"),
    @NamedQuery(name = "Course.findByFinancialHrs", query = "SELECT s FROM Course s WHERE s.financialHrs = :financialHrs"),
    @NamedQuery(name = "Course.findByEntryDate", query = "SELECT s FROM Course s WHERE s.entryDate = :entryDate"),
    @NamedQuery(name = "Course.findByTerminal", query = "SELECT s FROM Course s WHERE s.terminal = :terminal"),
    @NamedQuery(name = "Course.findByOsUser", query = "SELECT s FROM Course s WHERE s.osUser = :osUser")})

public class Course implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "COURSE_NO")
    private Integer courseNo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "COURSE_CODE")
    private String courseCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 70)
    @Column(name = "COURSE_NAME")
    private String courseName;
    @Size(max = 70)
    @Column(name = "COURSE_NAME_S")
    private String courseNameS;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CRD_HRS")
    private short crdHrs;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_AVG")
    private short isAvg;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_TRAINING")
    private short isTraining;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_THESIS")
    private short isThesis;
    @Column(name = "FINANCIAL_HRS")
    private Short financialHrs;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ENTRY_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date entryDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    private String terminal;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "OS_USER")
    private String osUser;
    @JoinColumn(name = "INSTRUCTOR_ID", referencedColumnName = "INSTRUCTOR_ID")
    @ManyToOne
    private Instructor instructor;
    @JoinColumn(name = "FACULTY_NO", referencedColumnName = "FACULTY_NO", insertable=false, updatable=false)
    @ManyToOne(optional = false)
    private Faculty faculty;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "course")
    private List<CourseDegree> courseDegreeList;
    @JoinColumns({
        @JoinColumn(name = "FACULTY_NO", referencedColumnName = "FACULTY_NO"),
        @JoinColumn(name = "DEPT_NO", referencedColumnName = "DEPT_NO")})
    @ManyToOne(optional = false)
    private Dept dept;

    public Course() {
    }

    public Course(Integer courseNo) {
        this.courseNo = courseNo;
    }

    public Course(Integer courseNo, String courseCode, String courseName, short crdHrs, short isAvg, short isTraining, short isThesis, Date entryDate, String terminal, String osUser) {
        this.courseNo = courseNo;
        this.courseCode = courseCode;
        this.courseName = courseName;
        this.crdHrs = crdHrs;
        this.isAvg = isAvg;
        this.isTraining = isTraining;
        this.isThesis = isThesis;
        this.entryDate = entryDate;
        this.terminal = terminal;
        this.osUser = osUser;
    }

    public Integer getCourseNo() {
        return courseNo;
    }

    public void setCourseNo(Integer courseNo) {
        this.courseNo = courseNo;
    }

    public String getCourseCode() {
        return courseCode;
    }

    public void setCourseCode(String courseCode) {
        this.courseCode = courseCode;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getCourseNameS() {
        return courseNameS;
    }

    public void setCourseNameS(String courseNameS) {
        this.courseNameS = courseNameS;
    }

    public short getCrdHrs() {
        return crdHrs;
    }

    public void setCrdHrs(short crdHrs) {
        this.crdHrs = crdHrs;
    }

    public short getIsAvg() {
        return isAvg;
    }

    public void setIsAvg(short isAvg) {
        this.isAvg = isAvg;
    }

    public short getIsTraining() {
        return isTraining;
    }

    public void setIsTraining(short isTraining) {
        this.isTraining = isTraining;
    }

    public short getIsThesis() {
        return isThesis;
    }

    public void setIsThesis(short isThesis) {
        this.isThesis = isThesis;
    }

    public Short getFinancialHrs() {
        return financialHrs;
    }

    public void setFinancialHrs(Short financialHrs) {
        this.financialHrs = financialHrs;
    }

    public Date getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(Date entryDate) {
        this.entryDate = entryDate;
    }

    public String getTerminal() {
        return terminal;
    }

    public void setTerminal(String terminal) {
        this.terminal = terminal;
    }

    public String getOsUser() {
        return osUser;
    }

    public void setOsUser(String osUser) {
        this.osUser = osUser;
    }

    public Instructor getInstructor() {
        return instructor;
    }

    public void setInstructor(Instructor instructor) {
        this.instructor = instructor;
    }

    public Faculty getFaculty() {
        return faculty;
    }

    public void setFaculty(Faculty faculty) {
        this.faculty = faculty;
    }

    public List<CourseDegree> getCourseDegreesList() {
        return courseDegreeList;
    }

    public void setCourseDegreesList(List<CourseDegree> CourseDegreesList) {
        this.courseDegreeList = CourseDegreesList;
    }
    
	public List<CourseDegree> getCourseDegreeList() {
		return courseDegreeList;
	}

	public void setCourseDegreeList(List<CourseDegree> courseDegreeList) {
		this.courseDegreeList = courseDegreeList;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (courseNo != null ? courseNo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Course)) {
            return false;
        }
        Course other = (Course) object;
        if ((this.courseNo == null && other.courseNo != null) || (this.courseNo != null && !this.courseNo.equals(other.courseNo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Courses[ courseNo=" + courseNo + " ]";
    }
    
}
